<template>


  <a-tooltip placement="right">
    <template #title>
      <span>关系说明</span>
    </template>
        <a-badge dot :count="'Y'== hasValue ? 1 : 0" :title='是否有关系说明'>
        <a-button size="small" @click="openModal">
           
              <template #icon>
                  <BlockOutlined />
              </template>
           <slot></slot>
        </a-button>
        </a-badge>
  </a-tooltip>



<a-modal
    :width="'90%'"
    v-model:open="open"
    title="Relationship Description"
    :footer="null"
    :maskClosable="false"
  >


    <BytemdForRela :cb="loadPageData" :mainId="props.mainId" :relaId="props.relaId" :classify="props.classify" :canEdit="props.canEdit"></BytemdForRela>
</a-modal>


</template>

<script setup>
import pmpHooks from "@/hooks/PmpHooks.js";
import { ref, reactive, toRaw,onMounted, markRaw, watch } from "vue";
import { BlockOutlined } from "@ant-design/icons-vue";
import BytemdForRela from '@/components/mdeditor/bytemd/BytemdForRela.vue'


const props = defineProps({
  mainId: {
    type: String,
    default: "",
  },
  relaId:{
    type: String,
    default: "",
  },
  classify:{
    type: String,
    default: () => '',
  },
  canEdit: {
    type: Boolean,
    default: false,
  },
  queryHasValue:{
    type: Boolean,
    default: true,
  }
});

const open = ref(false);
function closeModal() {
  open.value = false;
}

function openModal() {
  // console.log('=====', props.id)
  // console.log('=====', data.value)
  open.value = true;
}


const hasValue = ref("N");
async function loadPageData() {
  // alert(props.id);
  if(props.queryHasValue){
    const res = await pmpHooks.queryHasRelaMd(props.mainId,props.relaId,props.classify);
    hasValue.value = res.msg;
  }
}
onMounted(async () => {
  await loadPageData();
  //   data.value = pmpHooks.loadPmpDictDetail(props.id)
  //   title.value = pmpHooks.loadPmpDictDetail(props.id).nameCn
});

watch(
  () => props.relaId,
  async (v) => {
    await loadPageData();
    // data.value = pmpHooks.loadPmpDictDetail(v)
    // title.value = pmpHooks.loadPmpDictDetail(v).nameCn
  }
);


</script>

<style>
</style>